package 力扣日常刷题.木23一月.第11天311;

/**
 * @author 帅小伙
 * @date 2022/3/11
 * @description
 */
public class Demo45斐波那契额数列 {


    public int fib(int n) {
        if(n < 2) return n;
        final int MOD = 1000000007;
        int a = 0,b = 1;
        for (int i = 2; i <= n; i++) {
            int t = b;
            b = (a+b) % MOD;
            a = t % MOD;
        }
        return b;
    }

}
